Since there's a lot of normal text in comments and string literals, CC Mode provides features to edit these like in text mode. The goal is to do it seamlessly, i.e. you can use auto fill mode, sentence and paragraph movement, paragraph filling, adaptive filling etc. wherever there's a piece of normal text without having to think much about it. CC Mode keeps the indentation, fixes suitable comment line prefixes, and so on.
You can configure the exact way comments get filled and broken, and where Emacs does auto-filling (see see Custom Filling and Breaking). Typically, the style system (see Styles) will have set this up for you, so you probably won't have to bother.
Line breaks are by default handled (almost) the same regardless of whether they are made by auto fill mode (see Auto Fill), by paragraph filling (e.g. with M-q), or explicitly with M-j or similar methods. In string literals, the new line gets the same indentation as the previous nonempty line.1.
c-fill-paragraph)The formatting of the starters (/*) and
enders (*/) of block comments are kept as they
were before the filling. I.e., if either the starter or ender
were on a line of its own, then it stays on its own line;
conversely, if the delimiter has comment text on its line, it
keeps at least one word of that text with it on the line.
This command is the replacement for
fill-paragraph in CC Mode buffers.
c-indent-new-comment-line)indent-new-comment-line.c-indent-new-comment-line. In normal code it's
indented like newline-and-indent would do. In
macros it acts like newline-and-indent but
additionally inserts and optionally aligns the line ending
backslash so that the macro remains unbroken. See Custom Macros, for
details about the backslash alignment. In a string, a
backslash is inserted only if the string is within a
macro2.
This function is not bound to a key by default, but it's
intended to be used on the RET key. If you like
the behavior of newline-and-indent on
RET, you should consider switching to this
function. See Sample
.emacs File.
c-context-line-break is to RET. I.e. it
works just like c-context-line-break but leaves
the point before the inserted line break.[1] You can change this default by setting
the string syntactic symbol (see Syntactic
Symbols and see Customizing
Indentation)
[2] In GCC, unescaped line breaks within strings are valid.